/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wumpusworld;

import ArtificialAgent.ArtificialAgent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

/**
 *
 * @author Macias
 */
class MyMouseMotionListener implements MouseMotionListener{

    private MyCanvas canvas;
    int height,width;
    int oldPosX,oldPosY=-1;
    ArtificialAgent artifAgent;

    MyMouseMotionListener(MyCanvas canvas, ArtificialAgent artifAgent) {
        this.canvas = canvas;
        height= canvas.getHeight();
        width=canvas.getWidth();
        this.artifAgent = artifAgent;
    }

    public void mouseDragged(MouseEvent e) {
    }

    public void mouseMoved(MouseEvent e) {
        if(canvas.showHints){
            if(e.getX()>19 && e.getY()>19 && e.getX()<(width-20) && e.getY()<(height-20)){
                int posX = (e.getX()-20)*canvas.map.length/(width-40);
                int posY = (e.getY()-20)*canvas.map[0].length/(height-40);

                if(oldPosX!=posX || oldPosY!=posY){
                    float noteW , noteP ;      //

                    noteW = artifAgent.getTrueProbability(posX, posY, "wumpus");
                    noteP = artifAgent.getTrueProbability(posX, posY, "pit");


                    canvas.drawHint(posX,posY,noteW,noteP);
//                    canvas.repaint();
                    oldPosX=posX;
                    oldPosY=posY;
                }
            }
            else{
                canvas.drawHint(-1, -1, -1, -1);    //mouse is not over the canvas- do not draw hints
            }


        }
    }


}
